<template>
  <div class="article-list">
    <slot name="title"></slot>
    <div class="article-content">
      <div class="article-item" v-for="item in articleList" :key="item.id">
        <div class="item-left">
          <a
            href="javascript:;"
            class="item-tag"
            @click="handleDetails(item.path)"
            >{{ item.tag }}</a
          >
          <a
            href="javascript:;"
            class="item-img"
            @click="handleDetails(item.path, '/content-article/' + item.id)"
          >
            <img :src="item.imgHost + item.imgUrl" alt="" />
          </a>
        </div>
        <div class="item-right">
          <a
            href="javascript:;"
            class="item-title"
            @click="handleDetails(item.path, '/content-article/' + item.id)"
          >
            {{ item.title }}
          </a>
          <div class="item-introduce">
            {{ item.introduce }}
          </div>
          <div class="item-foot">
            <div class="item-foot-left">{{ item.createTime }}</div>
            <div class="item-foot-right">
              <span class="iconfont icon-dianzan1">{{ item.like_num }}</span>
              <span class="iconfont icon-Icon-guankanliang">{{
                item.look_num
              }}</span>
              <span class="iconfont icon-xiaoxi">0</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// import { getArticle } from "@/api/api";
import { mapState, mapActions, mapMutations } from "vuex";
export default {
  name: "ArticleList",
  props: {
    articleList: {
      type: Array,
    },
  },
  data() {
    return {};
  },
  methods: {
    ...mapActions(["handleSetActiveArr"]),
    async handleDetails(path, pathId) {
      await this.handleSetActiveArr({path,app:this});
      if (pathId) {
        this.$router.push({
          path: pathId,
        });
      } else {
        this.$router.push({
          path,
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
@media only screen and (min-width: 1240px) {
  .item-title {
    -webkit-line-clamp: 2;
  }
  .item-img {
    height: 154px;
  }
}
@media only screen and (min-width: 992px) and (max-width: 1240px) {
  .item-title {
    -webkit-line-clamp: 1;
  }
  .item-img {
    height: 124px;
  }
}
@media only screen and (max-width: 992px) {
  .item-title {
    -webkit-line-clamp: 1;
  }
  .item-img {
    height: 130px;
  }
}
@media only screen and (max-width: 768px) {
  .item-title {
    font-size: 17px !important;
    -webkit-line-clamp: 2;
  }
  .item-tag {
    display: none;
  }
  .item-img {
    height: initial;
  }
  .item-introduce {
    display: none !important;
  }
  .icon-dianzan1 {
    display: none !important;
  }
  .icon-xiaoxi {
    display: none !important;
  }
}
.article-list {
  padding-bottom: 20px;
  background: #fff;
  .article-title {
    font-size: 22px;
    padding: 20px;
  }
  .article-content {
    padding: 0 20px 20px;
    .article-item {
      display: flex;
      padding: 20px 0;
      border-bottom: 1px solid #eee;
      .item-left {
        flex: 2;
        max-height: 154px;
        position: relative;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
        .item-tag {
          position: absolute;
          top: 15px;
          left: 10px;
          padding: 4px 8px;
          font-size: 12px;
          border-radius: 3px;
          color: #fff;
          background: rgba(0, 0, 0, 0.6);
        }
        .item-img {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 100%;
          img {
            transition: all 0.2s;
            width: 100%;
          }
          &:hover {
            img {
              width: 110%;
            }
          }
        }
      }
      .item-right {
        flex: 4;
        padding-left: 20px;
        position: relative;
        .item-title {
          line-height: 1.5;
          color: #000;
          font-size: 20px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          overflow: hidden;
          margin-bottom: 10px;
        }
        .item-introduce {
          line-height: 1.625;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          overflow: hidden;
          color: #333;
        }
        .item-foot {
          position: absolute;
          bottom: 0;
          width: 96%;
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 12px;
          color: #333;
          line-height: 24px;
          .iconfont {
            font-size: 12px;
            padding-left: 10px;
            &::before {
              width: 14px;
              height: 14px;
              padding-right: 2px;
            }
          }
        }
      }
    }
    .article-img {
      padding: 80px 0;
      text-align: center;
      img {
        width: 240px;
        max-width: 60%;
        margin: 20px 0;
      }
      p {
        font-size: 14px;
        color: #262626;
      }
    }
  }
  .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(56, 56, 56, 0.8);
    text-align: center;
    font-size: 13px;
    span {
      height: 28px;
      line-height: 28px;
      border-radius: 2px;
      padding: 0 8px;
      margin: 0 5px;
      background: #f4f4f5;
    }
    div {
      width: 30px;
      height: 28px;
      line-height: 28px;
      box-sizing: border-box;
      border-radius: 2px;
      padding: 0 8px;
      margin: 0 5px;
      background: #f4f4f5;
      cursor: pointer;
      &:hover {
        color: #fff;
        background: #3361ea;
      }
    }
    .input-page {
      position: relative;
      width: 66px;
      height: 28px;
      padding: 0;
      display: flex;
      align-items: center;
      input {
        width: 66px;
        height: 28px;
        padding-left: 10px;
        border: 1px solid #eee;
        box-sizing: border-box;
        outline: none;
      }
      i {
        width: 28px;
        position: absolute;
        top: 0;
        right: 0;
        padding: 0 5px;
        box-sizing: border-box;
        color: #333;
        &:hover {
          color: #0088cc;
        }
      }
    }
  }
}
</style>